/**
 * description:store
 * */
import Vue from 'vue';
import Vuex from 'vuex';

Vue.use(Vuex);

export default new Vuex.Store({
    state: {
        /* 登录token */
        adminToken: '',
    },
    getters: {},
    mutations: {
        /* 设置token信息 */
        setToken(state, payload) {
            state.adminToken = payload;
            if (window.localStorage) {
                window.localStorage.adminToken = payload;
            }
        },
        initToken(state) {
            if (window.localStorage && window.localStorage.adminToken) {
                state.adminToken = window.localStorage.adminToken;
            }
        },

    },
    actions: {
        initAllState({ commit }) {
            commit('initToken');
        },

    },
    modules: {}
});
